package com.uestc.utils;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;

public class CopyUtil {
    public static void copyFile(List<File> sourceFiles, String destPath) {
        for (File file : sourceFiles) {
            try (FileInputStream fis = new FileInputStream(file.getPath());
                 FileOutputStream fos = new FileOutputStream(destPath + "/" + file.getName())) {

                byte[] buffer = new byte[1024];
                int length;
                while ((length = fis.read(buffer)) > 0) {
                    fos.write(buffer, 0, length);
                }

                System.out.println("文件拷贝成功！");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
